Resources for this: http://ocw.mit.edu/courses/mechanical-engineering/2-71-optics-spring-2009/video-lectures/lecture-16-gratings-amplitude-and-phase-sinusoidal-and-binary/MIT2_71S09_lec16.pdf - Page 6 on Phase gratings
In [1]:
import numpy as np
%pylab
from numpy.fft import fft, fftshift
In [2]:
n = 1.5
l = 780e-9
k = 2*pi/l
x = linspace(-300,300,600)*20e-6
L = 5000*l
s = 780e-9/10.0
m = k*(n-1)*s
#fieldout = np.exp(1j*m/2.0*sin(2*pi*x/L)) # a sinusoidal phase variation
noise = array([np.random.ranf() for i in x])
fieldout = np.exp(1j*m/2.0*noise)
In [3]:
plot(fftfreq(600,20e-6),np.abs(fft(fieldout)),".-")
Out[3]:
In [4]:
L
Out[4]:
4 mm grating wavelength... with 1/10 wavelength variation. This is essentially the limit to the flatness of any glass optic.
In [5]:
from scipy.signal import spline_filter
In [6]:
smoothed = spline_filter(noise.reshape((600,1)),1)
In [7]:
plot(smoothed)
Out[7]:
In [8]:
plot(noise)
Out[8]:
In [ ]: